package LeetCode;

//
// Created by ✎﹏ℳ๓独赏☆独醉 on 2024/6/14.
// 
public class 位1的个数 {
    public static void main(String[] args) {

    }
    public static int hammingWeight(int n) {
        String str = Integer.toBinaryString(n);
        int count = 0;
        for (int i = 0; i < str.length(); i++) {
            if(str.charAt(i) == '1'){
                count++;
            }
        }
        return count;
    }
}
